<?php

namespace app\api\controller\shop;


use app\common\controller\Api;
use app\common\model\Area;


/**
 *
 */
class Shopfile extends Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = ['*'];

    protected $app = null;

    public function add()
    {

        $shop_id =  $this->request->param('shop_id');
        $idcard1 =  $this->request->param('idcard1');
        $idcard2 =  $this->request->param('idcard2');
        $ht1 =  $this->request->param('ht1');
        $ht2 =  $this->request->param('ht2');
        $yyzz =  $this->request->param('yyzz');
        $mt =  $this->request->param('mt');
        $bank =  $this->request->param('bank');
        $auth =  $this->request->param('auth');

        $shopFileModel = new \app\admin\model\Shopfile();
        $obj = array();
        $obj['idcard1'] = $idcard1;
        $obj['idcard2'] = $idcard2;
        $obj['ht1'] = $ht1;
        $obj['ht2'] = $ht2;
        $obj['yyzz'] = $yyzz;
        $obj['mt'] = $mt;
        $obj['bank'] = $bank;
        $obj['auth'] = $auth;
        $file = $shopFileModel->where('shop_id',$shop_id)->find();
        if($file){
            $shopFileModel->where('shop_id',$shop_id)->update(['shop_id'=>$shop_id,'image'=>json_encode($obj),'create_time'=>time()]);
        }else{
            $shopFileModel->insert(['shop_id'=>$shop_id,'image'=>json_encode($obj),'create_time'=>time()]);

        }

        $this->success('成功');


    }

    public function info()
    {

        $shop_id =  $this->request->param('shop_id');
        $shopFileModel = new \app\admin\model\Shopfile();
        $shopFile = $shopFileModel->where('shop_id',$shop_id)->find();
        if($shopFile){
            $shopFile['image'] = json_decode($shopFile['image'],true);

        }

        $this->success('',$shopFile);
    }
}
